import com from './addon/com'

var components = com([
	'HeaderLayout',
	'HeaderDock',
	'LayoutMain',
	'LayoutBox',
	'Btn',
	'Icon',
	'FormGroup',
	'FormInput',
	'GridRow'
])

//

new Vue({
	el: '#app',
	components: components,
	methods: {
		submit: function(){
			this.$broadcast('form-verify', '');
			if(this.$refs.form.pass){
				console.log('sending data')
				console.log(this.$refs.form.data);
				var _this = this;
				$.ajax({
					url: SITE_URL + '/passport/login_v2',
					type:'post',
					data: this.$refs.form.data,
					success: function(data){
						if(!data.code){
							_this.$refs.form.setNotice(data.msg)
						} else {
							// 要重置密码
							if(data.data.redirect){
								window.location = SITE_URL + '/passport/resetpassword'
							} else {
								// 不用重置密码
								window.location = SITE_URL + '/home'
							}

						}
					},
					error: function(){

					}
				});
			} else {
				//this.$refs.myform.setNotice('账号密码不正确')
				console.log('data wrong')
			}
		}
	}
})
